package com.lagou.rabbitmq.demo;

import com.lagou.rabbitmq.demo.controller.PayController;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Component
public class OrderDlxListener {

    // 过期的订单队列
    public static List<String> list = new ArrayList<>();
    /**
     * 监听死信队列
     */
    @RabbitListener(queues = "dlx.queue")
    public void orderConsumer(String message) {
        // 如果待支付状态
        if(PayController.status.equals("待支付")){
            list.add(message);
            System.out.println(message + "订单过期.");
        }
    }
}
